<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>首页</title>
</head>

<body>
  <h1>首页</h1>
  <a href="/login">登录</a>
  <h3>帖子列表</h3>
  <ul></ul>
  <script>
    fetch('/posts')
      .then(res => res.json())
      .then(posts => {
        let html = ''
        for (const post of posts) {
          html += `<li>${post.title}</li>`
        }
        document.querySelector('ul').innerHTML = html
      })
  </script>
</body>

</html>